import { reqGetDetail } from '@/api'

const actions = {
  // 获取详情的回调
  async getDetail({ commit, state, dispatch, getters }, skuId) {
    let res = await reqGetDetail(skuId)
    commit('GETDETAIL',res.data)
    // console.log(res);
  },
  // 通过id拿到手机的详细信息
  async getAddOrChange({ commit, state, dispatch, getters }, skuId){
    // console.log(skuId);
  let res =  await reqGetDetail(skuId)
  if (res.code ===200) {
    // 状态码为200
    commit('GETDETAIL',res.data)
  }
  // console.log(res);
  }
}

const mutations = {
  // 获取详情的回调
  GETDETAIL(state,value){
      state.detailList = value  //二次赋值
  }
}

const state = {
  detailList:{} //准备初始数据
}

const getters = {
    
}

export default {
  actions,
  mutations,
  state,
  getters
}
